package com.xubeihong.xubeihong;

import com.alibaba.fastjson2.JSONObject;
import com.xubeihong.xubeihong.constant.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.concurrent.Callable;

@Component
public class TicketTask implements Runnable {

    @Autowired
    private CacheManager cacheManager;

    @Override
    public void run() {

        Integer flag = (Integer) cacheManager.getCache("ticket").get(Constant.id+"_"+Constant.myPhone, Integer.class);
        if(null!=flag){
            return;
        }
        JSONObject result = HttpTool.post();
        Integer status =result.getInteger("status");
        if(0==status && "您已预约".equals(result.getString("msg"))){
            cacheManager.getCache("ticket").put(Constant.id+"_"+Constant.myPhone, 1);
        }
        System.out.println("status:"+status);
    }
}
